IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spTnotify_RetrieveAll')
	BEGIN
		PRINT 'Dropping Procedure spTnotify_RetrieveAll'
		DROP  Procedure  spTnotify_RetrieveAll
	END

GO

PRINT 'Creating Procedure spTnotify_RetrieveAll'
GO

CREATE Procedure spTnotify_RetrieveAll
	(
		@UniqueID int = null, 
		@msgtype char(8) = null, 
		@empno char(10) = null, 
		@tfileno char(20) = null, 
		@ILPno char(20) = null, 
		@msgtxt char(255) = null, 
		@fstatus char(10) = null, 
		@tdatetime DateTime = null
	)
AS
    /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 9/6/2007	Initial version created
    ------------------------------------------------------------------------------
    */
	
	SET NOCOUNT ON
	
	-- Retrieve the relevant records
	SELECT  *
	FROM	Tnotify
	
	WHERE	(@UniqueID IS NULL OR Tnotify.UniqueID = @UniqueID)
	  AND	(@msgtype IS NULL OR Tnotify.msgtype = @msgtype)
	  AND	(@empno IS NULL OR Tnotify.empno = @empno)
	  AND	(@tfileno IS NULL OR Tnotify.tfileno = @tfileno)
	  AND	(@ILPno IS NULL OR Tnotify.ILPno = @ILPno)
	  AND	(@msgtxt IS NULL OR Tnotify.msgtxt = @msgtxt)
	  AND	(@fstatus IS NULL OR Tnotify.fstatus = @fstatus)
	  AND	(@tdatetime IS NULL OR Tnotify.tdatetime = @tdatetime)

	-- Return to calling method
	RETURN
GO
